Switch from the deprecated 'Drive' to ':=='
This commit is contained in:
parent
5e0f510bef
commit
41914ade2c
@ -17,17 +17,17 @@ Top = subclass Elaboratable where
|
||||
pulser = (Submodule.pulser $ Pulser$ freq // 2).out
|
||||
seg7 = Submodule.seg7$ Segment7x2 decimal: False
|
||||
|
||||
Comb$ Drive @ledr blinker
|
||||
Comb$ @ledr :== blinker
|
||||
|
||||
ff = Signal 1 reset: 1
|
||||
When pulser $ ->
|
||||
Sync$ Drive ff ~ff
|
||||
Sync$ ff :== ~ff
|
||||
|
||||
Comb$ Drive @ledg ff
|
||||
Comb$ @ledg :== ff
|
||||
|
||||
counter = Signal 4
|
||||
When pulser $ ->
|
||||
Sync$ Drive counter (counter + 1)
|
||||
Sync$ counter :== counter + 1
|
||||
|
||||
# TODO: learn SPI FLASH
|
||||
mem = Memory
|
||||
@ -35,13 +35,13 @@ Top = subclass Elaboratable where
|
||||
depth: 16 # ew
|
||||
init: ([0xde, 0xad, 0xbe, 0xef]*4)
|
||||
rdport = Submodule.rdport$ mem.read_port!
|
||||
Comb$ Drive rdport.addr counter
|
||||
Comb$ rdport.addr :== counter
|
||||
|
||||
|
||||
|
||||
Comb$ Drive seg7.number rdport.data
|
||||
#Comb$ Drive seg7.number counter
|
||||
Comb$ Drive @seg7 (Cat seg7.segs seg7.select)
|
||||
Comb$ seg7.number :== rdport.data
|
||||
#Comb$ seg7.number :== counter
|
||||
Comb$ @seg7 :== Cat seg7.segs seg7.select
|
||||
|
||||
|
||||
|
||||
@ -56,20 +56,20 @@ Top = subclass Elaboratable where
|
||||
@btn_l = platform.request "button" 3
|
||||
|
||||
state = Signal 4 reset: 0b1000
|
||||
Comb$ Drive @leds state
|
||||
Comb$ Drive @ledm (@btn_r | @btn_l)
|
||||
Comb$ @leds :== state
|
||||
Comb$ @ledm :== (@btn_r | @btn_l)
|
||||
|
||||
When (on_rising_edge @btn_l) $ ->
|
||||
Sync$ Drive state (state.rotate_left 1)
|
||||
Sync$ state :== state.rotate_left 1
|
||||
When (on_rising_edge @btn_r) $ ->
|
||||
Sync$ Drive state (state.rotate_right 1)
|
||||
Sync$ state :== state.rotate_right 1
|
||||
When (on_rising_edge @btn_m) $ ->
|
||||
Sync$ Drive state ~state
|
||||
Sync$ state :== ~state
|
||||
|
||||
|
||||
on_rising_edge = signal ->
|
||||
prev = Signal (signal.shape!)
|
||||
Sync$ Drive prev signal
|
||||
Sync$ prev :== signal
|
||||
~ signal.implies prev
|
||||
|
||||
|
||||
|
@ -8,11 +8,11 @@ Blinker = subclass Elaboratable where
|
||||
|
||||
elaborate = platform ~> m where with m = Module! =>
|
||||
counter = Signal$ range (@ncycles + 1)
|
||||
Sync$ Drive counter (counter - 1)
|
||||
Sync$ counter :== counter - 1
|
||||
|
||||
When (counter == 0) $ ->
|
||||
Sync$ Drive @out (~ @out)
|
||||
Sync$ Drive counter @ncycles
|
||||
Sync$ @out :== ~ @out
|
||||
Sync$ counter :== @ncycles
|
||||
|
||||
if __name__ == "__main__" =>
|
||||
blinker = Blinker ncycles: 10000000
|
||||
|
@ -7,14 +7,14 @@ Pulser = subclass Elaboratable where
|
||||
@out = Signal!
|
||||
|
||||
elaborate = platform ~> m where with m = Module! =>
|
||||
Sync$ Drive @out LOW
|
||||
Sync$ @out :== 0
|
||||
|
||||
counter = Signal$ range (@ncycles + 1)
|
||||
Sync$ Drive counter (counter - 1)
|
||||
Sync$ counter :== counter - 1
|
||||
|
||||
When (counter == 0) $ ->
|
||||
Sync$ Drive @out HIGH
|
||||
Sync$ Drive counter @ncycles
|
||||
Sync$ @out :== HIGH
|
||||
Sync$ counter :== @ncycles
|
||||
|
||||
if __name__ == "__main__" =>
|
||||
pulser = Pulser ncycles: 10000000
|
||||
|
@ -13,21 +13,20 @@ Segment7x2 = subclass Elaboratable where
|
||||
|
||||
elaborate = platform ~> m where with m = Module! =>
|
||||
select = Signal!
|
||||
Sync$ Drive select ~select
|
||||
Sync$ select :== ~select
|
||||
|
||||
seg7 = Submodule$ Segment7!
|
||||
|
||||
if not @decimal =>
|
||||
Comb$ Drive seg7.number $ Mux select
|
||||
@number >> 4
|
||||
@number & 0x0f
|
||||
if @decimal =>
|
||||
Comb$ Drive seg7.number $ Mux select
|
||||
Comb$ seg7.number :== if
|
||||
@decimal => Mux select
|
||||
@number // 10
|
||||
@number % 10
|
||||
otherwise => Mux select
|
||||
@number >> 4
|
||||
@number & 0x0f
|
||||
|
||||
Comb$ Drive @segs seg7.segs
|
||||
Comb$ Drive @select select
|
||||
Comb$ @segs :== seg7.segs
|
||||
Comb$ @select :== select
|
||||
|
||||
|
||||
Segment7 = subclass Elaboratable where
|
||||
@ -37,22 +36,22 @@ Segment7 = subclass Elaboratable where
|
||||
|
||||
elaborate = platform ~> m where with m = Module! =>
|
||||
Switch @number
|
||||
0x0 ,-> Comb$ Drive @segs 0b0111111
|
||||
0x1 ,-> Comb$ Drive @segs 0b0000110
|
||||
0x2 ,-> Comb$ Drive @segs 0b1011011
|
||||
0x3 ,-> Comb$ Drive @segs 0b1001111
|
||||
0x4 ,-> Comb$ Drive @segs 0b1100110
|
||||
0x5 ,-> Comb$ Drive @segs 0b1101101
|
||||
0x6 ,-> Comb$ Drive @segs 0b1111101
|
||||
0x7 ,-> Comb$ Drive @segs 0b0000111
|
||||
0x8 ,-> Comb$ Drive @segs 0b1111111
|
||||
0x9 ,-> Comb$ Drive @segs 0b1101111
|
||||
0xa ,-> Comb$ Drive @segs 0b1110111
|
||||
0xb ,-> Comb$ Drive @segs 0b1111100
|
||||
0xc ,-> Comb$ Drive @segs 0b0111001
|
||||
0xd ,-> Comb$ Drive @segs 0b1011110
|
||||
0xe ,-> Comb$ Drive @segs 0b1111001
|
||||
0xf ,-> Comb$ Drive @segs 0b1110001
|
||||
0x0 ,-> Comb$ @segs :== 0b0111111
|
||||
0x1 ,-> Comb$ @segs :== 0b0000110
|
||||
0x2 ,-> Comb$ @segs :== 0b1011011
|
||||
0x3 ,-> Comb$ @segs :== 0b1001111
|
||||
0x4 ,-> Comb$ @segs :== 0b1100110
|
||||
0x5 ,-> Comb$ @segs :== 0b1101101
|
||||
0x6 ,-> Comb$ @segs :== 0b1111101
|
||||
0x7 ,-> Comb$ @segs :== 0b0000111
|
||||
0x8 ,-> Comb$ @segs :== 0b1111111
|
||||
0x9 ,-> Comb$ @segs :== 0b1101111
|
||||
0xa ,-> Comb$ @segs :== 0b1110111
|
||||
0xb ,-> Comb$ @segs :== 0b1111100
|
||||
0xc ,-> Comb$ @segs :== 0b0111001
|
||||
0xd ,-> Comb$ @segs :== 0b1011110
|
||||
0xe ,-> Comb$ @segs :== 0b1111001
|
||||
0xf ,-> Comb$ @segs :== 0b1110001
|
||||
|
||||
|
||||
if __name__ == "__main__" =>
|
||||
|
Loading…
Reference in New Issue
Block a user