Skip to content

Commit

Permalink
move JTAG to its own domain
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrolarus committed Oct 11, 2023
1 parent 0a011ea commit 849fc40
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 187 deletions.
10 changes: 7 additions & 3 deletions clash-vexriscv-sim/app/HdlTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import VexRiscv
circuit ::
"CLK" ::: Clock System ->
"RST" ::: Reset System ->
"TCK" ::: Clock System ->
"INPUT" ::: Signal System Input ->
"OUTPUT" ::: Signal System Output
circuit clk rst input =
withClockResetEnable clk rst enableGen vexRiscv input
"JTAG_IN_" ::: Signal System JtagIn ->
"" :::
( "OUTPUT" ::: Signal System Output
, "JTAG_OUT_" ::: Signal System JtagOut)
circuit clk rst tck input jtagIn =
vexRiscv clk rst tck enableGen input jtagIn

makeTopEntity 'circuit

Expand Down
18 changes: 7 additions & 11 deletions clash-vexriscv-sim/src/Utils/Cpu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ emptyInput =
externalInterrupt = low,
softwareInterrupt = low,
iBusWbS2M = (emptyWishboneS2M @(BitVector 32)) {readData = 0},
dBusWbS2M = (emptyWishboneS2M @(BitVector 32)) {readData = 0},
jtagIn = JtagIn { testModeSelect = low, testDataIn = low, testClock = low }
dBusWbS2M = (emptyWishboneS2M @(BitVector 32)) {readData = 0}
}


Expand All @@ -53,12 +52,11 @@ cpu ::
)
cpu jtagPort bootIMem bootDMem = (output, writes, iS2M, dS2M)
where
output = vexRiscv input
(output, jtagOut) = vexRiscv hasClock hasReset hasClock jtagEnable input jtagIn


(jtagIn', _debugReset) = case jtagPort of
Just port -> unbundle $ unsafePerformIO $ jtagTcpBridge' (fromInteger port) hasReset (jtagOut <$> output)
Nothing -> (pure JTag.defaultIn, pure low)
(jtagEnable, jtagIn) = case jtagPort of
Just port -> unsafePerformIO $ jtagTcpBridge' (fromInteger port) jtagOut
Nothing -> (toEnable (pure False), pure JTag.defaultIn)
-- (unbundle -> (jtagIn', _debugReset)) = unsafePerformIO $ jtagTcpBridge' 7894 hasReset (jtagOut <$> output)

dM2S = dBusWbM2S <$> output
Expand All @@ -79,19 +77,17 @@ cpu jtagPort bootIMem bootDMem = (output, writes, iS2M, dS2M)
((0x0000_0000, dummyS2M) :> (0x4000_0000, bootDS2M) :> Nil)

input =
( \iBus dBus jtagIn ->
( \iBus dBus ->
Input
{ timerInterrupt = low,
externalInterrupt = low,
softwareInterrupt = low,
iBusWbS2M = makeDefined iBus,
dBusWbS2M = makeDefined dBus,
jtagIn = jtagIn
dBusWbS2M = makeDefined dBus
}
)
<$> iS2M
<*> dS2M
<*> jtagIn'

unBusAddr = mapAddr ((`shiftL` 2) . extend @_ @_ @2)

Expand Down
Loading

0 comments on commit 849fc40

Please sign in to comment.