diff --git a/compiler/characterizer/functional.py b/compiler/characterizer/functional.py index b1fbaada..db455e38 100644 --- a/compiler/characterizer/functional.py +++ b/compiler/characterizer/functional.py @@ -152,14 +152,6 @@ class functional(simulation): lower = bit * self.write_size upper = lower + self.write_size - 1 new_word = new_word[:lower] + old_word[lower:upper+1] + new_word[upper + 1:] - # if bit == self.num_wmask - 1: - # new_word = new_word[0:lower] + old_word[lower:upper+1] - # elif bit == 0: - # new_word = old_word[lower:upper + 1] + new_word[upper + 1:self.word_size] - # else: - # new_word = new_word[0:lower] + old_word[lower:upper+1] + new_word[upper+1:self.word_size] - - #wmask = wmask[:index] + "1" + wmask[index + 1:] # two ports cannot write to the same address if addr in w_addrs: @@ -221,15 +213,12 @@ class functional(simulation): return(1, "SUCCESS") def gen_wmask(self): - # wmask_bits = [None]*self.num_wmasks - # for bit in range(self.num_wmasks): - # rand = random.randint(0,1) - # wmask_bits[bit] = rand wmask = "" + # generate a random wmask for bit in range(self.num_wmasks): rand = random.randint(0, 1) wmask += str(rand) - # prevent the wmask from having all bits on + # prevent the wmask from having all bits on or off (not partial write) all_zeroes = True all_ones = True for bit in range(self.num_wmasks): @@ -243,10 +232,8 @@ class functional(simulation): elif all_ones: index = random.randint(0, self.num_wmasks - 1) wmask = wmask[:index] + "0" + wmask[index + 1:] - return wmask - - - # prevent the wmask from having all bits off + # wmask must be reversed since a python list goes right to left and sram bits go left to right. + return wmask[::-1] def gen_data(self): diff --git a/compiler/characterizer/simulation.py b/compiler/characterizer/simulation.py index 4cb8895b..84ec925d 100644 --- a/compiler/characterizer/simulation.py +++ b/compiler/characterizer/simulation.py @@ -271,7 +271,7 @@ class simulation(): t_current, t_current+self.period) elif op == "partial_write": - comment = "\tWriting {0} to address {1} with mask bit {2} (from port {3}) during cycle {4} ({5}ns - {6}ns)".format(word, + comment = "\tWriting (partial) {0} to address {1} with mask bit {2} (from port {3}) during cycle {4} ({5}ns - {6}ns)".format(word, addr, wmask, port, diff --git a/compiler/modules/port_data.py b/compiler/modules/port_data.py index 0b2fca51..e0979955 100644 --- a/compiler/modules/port_data.py +++ b/compiler/modules/port_data.py @@ -300,11 +300,8 @@ class port_data(design.design): temp.append(self.br_names[self.port]+"_out_{0}".format(bit)) if self.write_size is not None: - i = 0 - for bit in range(0,self.word_size,self.write_size): - for x in range(self.write_size): - temp.append("wdriver_sel_{}".format(i)) - i+=1 + for i in range(self.num_wmasks): + temp.append("wdriver_sel_{}".format(i)) else: temp.append("w_en") temp.extend(["vdd", "gnd"]) diff --git a/compiler/modules/write_driver_array.py b/compiler/modules/write_driver_array.py index 9e0f992f..5f71b038 100644 --- a/compiler/modules/write_driver_array.py +++ b/compiler/modules/write_driver_array.py @@ -30,6 +30,9 @@ class write_driver_array(design.design): self.write_size = write_size self.words_per_row = int(columns / word_size) + if self.write_size is not None: + self.num_wmasks = int(self.word_size/self.write_size) + self.create_netlist() if not OPTS.netlist_only: self.create_layout() @@ -61,7 +64,7 @@ class write_driver_array(design.design): self.add_pin("bl_{0}".format(i)) self.add_pin("br_{0}".format(i)) if self.write_size != None: - for i in range(self.word_size): + for i in range(self.num_wmasks): self.add_pin("en_{}".format(i)) else: self.add_pin("en") @@ -78,17 +81,23 @@ class write_driver_array(design.design): def create_write_array(self): self.driver_insts = {} + w = 0 + windex=0 for i in range(0,self.columns,self.words_per_row): name = "write_driver{}".format(i) index = int(i/self.words_per_row) self.driver_insts[index]=self.add_inst(name=name, mod=self.driver) - if self.write_size != None: + if self.write_size is not None: self.connect_inst(["data_{0}".format(index), "bl_{0}".format(index), "br_{0}".format(index), - "en_{0}".format(index), "vdd", "gnd"]) + "en_{0}".format(windex), "vdd", "gnd"]) + w+=1 + if w == self.write_size: + w = 0 + windex+=1 else: self.connect_inst(["data_{0}".format(index), "bl_{0}".format(index),