Skip to content

Commit 0fedc59

Browse files
committed
updated code/docs to reflect new, named, usage for bit and slice attributes with ucocotb
1 parent 67e69ec commit 0fedc59

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/examples/README.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -221,27 +221,31 @@ The first option would be to re-write all the cocotb.test() stuff to use only ui
221221

222222
Rather than do all that work, and have ugly `tt.ui_in.value[5]` stuff everywhere as a bonus, you can extend the DUT class to add in wrappers to these values.
223223

224-
To do this, you just derive a new class from `ttboard.cocotb.dut.DUT`, create the attributes using `new_bit_attribute` or `new_slice_attribute` (for things like `tt.ui_in[3:1]`).
224+
To do this, you just derive a new class from `ttboard.cocotb.dut.DUT`, create the attributes using `add_bit_attribute` or `add_slice_attribute` (for things like `tt.ui_in[3:1]`).
225225

226226
In my neptune case, this looks like:
227227

228228
```
229229
import ttboard.cocotb.dut
230230
231+
231232
class DUT(ttboard.cocotb.dut.DUT):
232233
def __init__(self):
233234
super().__init__('Neptune')
234235
self.tt = DemoBoard.get()
235236
# inputs
236-
self.display_single_select = self.new_bit_attribute(self.tt.ui_in, 7)
237-
self.display_single_enable = self.new_bit_attribute(self.tt.ui_in, 6)
238-
self.input_pulse = self.new_bit_attribute(self.tt.ui_in, 5)
239-
self.clk_config = self.new_slice_attribute(self.tt.ui_in, 4, 2) # tt.ui_in[4:2]
237+
self.add_bit_attribute('display_single_select', self.tt.ui_in, 7)
238+
self.add_bit_attribute('display_single_enable', self.tt.ui_in, 6)
239+
self.add_bit_attribute('input_pulse', self.tt.ui_in, 5)
240+
self.add_slice_attribute('clk_config', self.tt.ui_in, 4, 2) # tt.ui_in[4:2]
240241
# outputs
241-
self.prox_select = self.new_bit_attribute(self.tt.uo_out, 7)
242-
self.segments = self.new_slice_attribute(self.tt.uo_out, 6, 0) # tt.uo_out[6:0]
242+
self.add_bit_attribute('prox_select', self.tt.uo_out, 7)
243+
self.add_slice_attribute('segments', self.tt.uo_out, 6, 0) # tt.uo_out[6:0]
244+
243245
````
244246
247+
After instantiation, the DUT object will now have all the requisite attributes, e.g. `dut.segments`, `dut.clk_config` etc.
248+
245249
Using that class to construct my dut, things like
246250
247251
```

src/examples/tt_um_rgbled_decoder/tt_um_rgbled_decoder.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ def __init__(self, data:Wire, data_rdy:Wire):
192192
self.data = data
193193
self.data_rdy = data_rdy
194194
self.nreset = self.rst_n
195-
self.mosi = self.new_bit_attribute(self.tt.ui_in, 0)
196-
self.sclk = self.new_bit_attribute(self.tt.ui_in, 1)
197-
self.nsel = self.new_bit_attribute(self.tt.ui_in, 2)
195+
self.add_bit_attribute('mosi', self.tt.ui_in, 0)
196+
self.add_bit_attribute('sclk', self.tt.ui_in, 1)
197+
self.add_bit_attribute('nsel', self.tt.ui_in, 2)
198198

199199
class DUT(basedut.DUT):
200200
def __init__(self):
201201
super().__init__('RGBDUT')
202202
self.data = Wire()
203-
self.data_rdy = self.new_bit_attribute(self.tt.ui_in, 2)
203+
self.add_bit_attribute('data_rdy', self.tt.ui_in, 2)
204204
self.tbrgbled = RGBLED(self.data, self.data_rdy)
205205
self.tbspi = TBSPI(self.data, self.data_rdy)
206206

0 commit comments

Comments
 (0)