Skip to content

Commit f907b00

Browse files
committed
Synch with N5_SoC
1 parent 5b16308 commit f907b00

39 files changed

+2862
-928
lines changed

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1-
# Chameleon SoC
1+
# Chameleon SoC (IBEX)
22
AHB-Lite based SoC for IBEX
33

4+
## The Memory Map
5+
<img src="./docs/soc_mem_map.png" size="50%">
6+
7+
## Peripherals
8+
|Peripheral|Bus|Base Address|IRQ #|MPRJ I/O Pins|
9+
|----------|---|------------|--------|-----|
10+
|GPIO (14)|AHB|0x48000000|N/A|0-13|
11+
|UART0|APB|0x40000000|16|20-21|
12+
|UART1|APB|0x40100000|17|22-23|
13+
|SPI0|APB|0x40200000|18|24-27|
14+
|SPI1|APB|0x40300000|19|28-31|
15+
|I2C0|APB|0x40400000|20|32-33|
16+
|I2C1|APB|0x40500000|21|34-35|
17+
|PWM0|APB|0x40600000|n/a|26|
18+
|PWM1|APB|0x40700000|n/a|37|
19+
|TMR0|APB|0x40800000|22|n/a|
20+
|TMR1|APB|0x40900000|23|n/a|
21+
|TMR2|APB|0x40A00000|24|n/a|
22+
|TMR3|APB|0x40B00000|25|n/a|
23+
|WDT0|APB|0x40C00000|26|n/a|
24+
|WDT1|APB|0x40D00000|27|n/a|
25+

docs/soc_mem_map.png

20.8 KB
Loading

dv/23LC512.v

+627
Large diffs are not rendered by default.

dv/DFFRAM_beh.v

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module DFFRAM_beh #( parameter COLS=1)
2+
(
3+
CLK,
4+
WE,
5+
EN,
6+
Di,
7+
Do,
8+
A
9+
);
10+
localparam A_WIDTH = 8+$clog2(COLS);
11+
12+
input wire CLK;
13+
input wire [3:0] WE;
14+
input wire EN;
15+
input wire [31:0] Di;
16+
output reg [31:0] Do;
17+
input wire [(A_WIDTH - 1): 0] A;
18+
19+
reg [31:0] RAM[(256*COLS)-1 : 0];
20+
21+
always @(posedge CLK)
22+
if(EN) begin
23+
Do <= RAM[A];
24+
if(WE[0]) RAM[A][ 7: 0] <= Di[7:0];
25+
if(WE[1]) RAM[A][15:8] <= Di[15:8];
26+
if(WE[2]) RAM[A][23:16] <= Di[23:16];
27+
if(WE[3]) RAM[A][31:24] <= Di[31:24];
28+
end
29+
else
30+
Do <= 32'b0;
31+
32+
endmodule

dv/Chameleon_SoC_TB.v dv/IBEX_SoC_TB.v

+51-23
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
`timescale 1ns/1ns
22

33
`define TEST_FILE "../sw/test.hex"
4-
`define SIM_TIME 100_000
5-
`define SIM_LEVEL 4
4+
`define SIM_TIME 800_000
5+
`define SIM_LEVEL 0
66

7-
module Chameleon_SoC_TB;
7+
module IBEX_SoC_TB;
88

99
reg HCLK, HRESETn;
1010

@@ -52,6 +52,10 @@ module Chameleon_SoC_TB;
5252
wire [0: 0] sda_o_Sys0_SS0_S5;
5353
wire [0: 0] sda_oen_o_Sys0_SS0_S5;
5454

55+
wire [0: 0] pwm_Sys0_SS0_S6;
56+
wire [0: 0] pwm_Sys0_SS0_S7;
57+
58+
/* Program Flash */
5559
assign fdio = fdoe ? fdo : 4'bzzzz;
5660
assign fdi = fdio;
5761

@@ -65,9 +69,9 @@ module Chameleon_SoC_TB;
6569
.HCLK(HCLK),
6670
.HRESETn(HRESETn),
6771

68-
//input [7: 0] Input_DATA,
69-
//input [0: 0] Input_irq,
70-
//output Output_DATA,
72+
.SYSTICKCLKDIV(8'd100),
73+
.NMI(1'b0),
74+
7175
.fdi_Sys0_S0(fdi),
7276
.fdo_Sys0_S0(fdo),
7377
.fdoe_Sys0_S0(fdoe),
@@ -82,12 +86,10 @@ module Chameleon_SoC_TB;
8286

8387
.RsRx_Sys0_SS0_S0(RsRx_Sys0_SS0_S0),
8488
.RsTx_Sys0_SS0_S0(RsTx_Sys0_SS0_S0),
85-
//output wire [0: 0] uart_irq_Sys0_SS0_S0,
8689

8790
.RsRx_Sys0_SS0_S1(RsRx_Sys0_SS0_S1),
8891
.RsTx_Sys0_SS0_S1(RsTx_Sys0_SS0_S1),
89-
//output wire [0: 0] uart_irq_Sys0_SS0_S1,
90-
92+
9193
.MSI_Sys0_SS0_S2(MSI_Sys0_SS0_S2),
9294
.MSO_Sys0_SS0_S2(MSO_Sys0_SS0_S2),
9395
.SSn_Sys0_SS0_S2(SSn_Sys0_SS0_S2),
@@ -110,14 +112,39 @@ module Chameleon_SoC_TB;
110112
.scl_oen_o_Sys0_SS0_S5(scl_oen_o_Sys0_SS0_S5),
111113
.sda_i_Sys0_SS0_S5(sda_i_Sys0_SS0_S5),
112114
.sda_o_Sys0_SS0_S5(sda_o_Sys0_SS0_S5),
113-
.sda_oen_o_Sys0_SS0_S5(sda_oen_o_Sys0_SS0_S5)
114-
/*
115-
output wire [0: 0] pwm_Sys0_SS0_S6,
116-
output wire [0: 0] pwm_Sys0_SS0_S7 */
117-
//.db_reg_Sys0(db_reg_Sys0)
115+
.sda_oen_o_Sys0_SS0_S5(sda_oen_o_Sys0_SS0_S5),
116+
117+
.pwm_Sys0_SS0_S6(pwm_Sys0_SS0_S6),
118+
.pwm_Sys0_SS0_S7(pwm_Sys0_SS0_S7)
119+
118120
);
119121

120-
// Load the application into the flash memory
122+
// GPIO Loopback!
123+
wire [15:0] GPIO_PINS;
124+
generate
125+
genvar i;
126+
for(i=0; i<16; i=i+1)
127+
assign GPIO_PINS[i] = GPIOOEN_Sys0_S2[i] ? GPIOOUT_Sys0_S2[i] : 1'bz;
128+
endgenerate
129+
assign GPIO_PINS[15:8] = GPIO_PINS[7:0];
130+
assign GPIOIN_Sys0_S2 = GPIO_PINS;
131+
132+
133+
// Serial Terminal connected to UART0 TX*/
134+
terminal term(.rx(RsTx_Sys0_SS0_S0));
135+
136+
// SPI SRAM connected to SPI0
137+
wire SPI_HOLD = 1'b1;
138+
M23LC512 SPI_SRAM(
139+
.RESET(~HRESETn),
140+
.SO_SIO1(MSI_Sys0_SS0_S2),
141+
.SI_SIO0(MSO_Sys0_SS0_S2),
142+
.CS_N(SSn_Sys0_SS0_S2),
143+
.SCK(SCLK_Sys0_SS0_S2),
144+
.HOLD_N_SIO3(SPI_HOLD)
145+
);
146+
147+
// Load the application into the flash memory
121148
initial begin
122149
#1 $readmemh(`TEST_FILE, flash.I0.memory);
123150
end
@@ -138,28 +165,29 @@ module Chameleon_SoC_TB;
138165

139166
// Dump file
140167
initial begin
141-
$dumpfile("Chameleon_SoC_TB.vcd");
142-
$dumpvars(`SIM_LEVEL, Chameleon_SoC_TB);
168+
$dumpfile("IBEX_SoC_TB.vcd");
169+
$dumpvars(`SIM_LEVEL, IBEX_SoC_TB);
143170
#`SIM_TIME;
144171
$finish;
145172
end
146173

147174
// Terminate the smulation with ebreak instruction.
148175
// Calculate the CPI using the CSRs
149-
//always @ (posedge HCLK)
150-
//if(MUV.CPU.N5.instr_ebreak) begin
176+
/*
177+
always @ (posedge HCLK)
178+
if(MUV.CPU.N5.instr_ebreak) begin
151179
//$display("CPI=%d.%0d", MUV.N5.CSR_CYCLE/MUV.N5.CSR_INSTRET,(MUV.N5.CSR_CYCLE%MUV.N5.CSR_INSTRET)*10/MUV.N5.CSR_INSTRET );
152-
//$finish;
153-
//end
154-
180+
$finish;
181+
end
182+
*/
155183

156184
// Monitor Flash memory reads
157185
//always @(posedge HCLK)
158186
// if(MUV.N5.HTRANS[1] & MUV.N5.HREADY & MUV.N5.HSEL_FLASH)
159187
// $display("Flash Read A:%X (%0t)", HADDR, $time);
160188

161189

162-
terminal term(.rx(RsTx_Sys0_SS0_S0));
190+
163191
endmodule
164192

165193
module terminal #(parameter bit_time = 160) (input rx);

dv/Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ test.hex: ../sw/test.c ../sw/crt0.S ../sw/link.ld
77
test.vvp: test.hex files.list
88
iverilog -o test.vvp -D TEST_FIL="../sw/test.hex" -c files.list
99

10-
sim: test.vvp
10+
test_fast.vvp: test.hex files_fast_sim.list
11+
iverilog -o test_fast.vvp -D TEST_FIL="../sw/test.hex" -c files_fast_sim.list
12+
13+
sim: test.vvp
1114
./test.vvp
1215

16+
sim_fast: test_fast.vvp
17+
./test_fast.vvp
1318

1419
clean:
1520
rm *.vvp

dv/files.list

+11-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@
2424
../rtl/IPs/APB_UART.v
2525
../rtl/IPs/APB_SPI.v
2626
../rtl/IPs/APB_I2C.v
27-
../rtl/IPs/DFFRAM.v
28-
../rtl/IPs/DFFRAMBB.v
27+
../dv/DFFRAM_beh.v
28+
+define+HC_CACHE=1
2929
../rtl/IPs/QSPI_XIP_CTRL.v
3030
../rtl/IPs/AHBSRAM.v
31+
../rtl/IPs/DFFRAM.v
32+
../rtl/IPs/DFFRAMBB.v
33+
../rtl/IPs/RAM_3Kx32.v
34+
../rtl/acc/AHB_SPM.v
35+
36+
#+define+USE_DFFRAM_BEH=1
37+
../rtl/soc_core.v
3138

3239
../rtl/ibex/ibex_wrapper.v
3340
../rtl/ibex/ibex_alu.v
@@ -55,8 +62,6 @@
5562
../rtl/ibex/prim_clock_gating.v
5663
../rtl/ibex/ibex_register_file_ff.v
5764

58-
59-
Chameleon_SoC_TB.v
65+
IBEX_SoC_TB.v
6066
sst26wf080b.v
61-
../rtl/soc_core.v
62-
../rtl/DFFRFile.v
67+
23LC512.v

dv/files_fast_sim.list

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
../pdk/hd_primitives.v
2+
../pdk/hd_functional.v
3+
4+
../rtl/AHB_sys_0/AHBlite_sys_0.v
5+
../rtl/AHB_sys_0/AHBlite_bus0.v
6+
../rtl/AHB_sys_0/AHBlite_GPIO.v
7+
../rtl/AHB_sys_0/AHBlite_db_reg.v
8+
9+
#-y ../rtl/AHB_sys_0/APB_sys_0/
10+
../rtl/AHB_sys_0/APB_sys_0/APB_WDT32.v
11+
../rtl/AHB_sys_0/APB_sys_0/APB_TIMER32.v
12+
../rtl/AHB_sys_0/APB_sys_0/APB_PWM32.v
13+
../rtl/AHB_sys_0/APB_sys_0/AHB_2_APB.v
14+
../rtl/AHB_sys_0/APB_sys_0/APB_bus0.v
15+
../rtl/AHB_sys_0/APB_sys_0/APB_sys_0.v
16+
17+
#-y ../rtl/IPs
18+
../rtl/IPs/TIMER32.v
19+
../rtl/IPs/PWM32.v
20+
../rtl/IPs/WDT32.v
21+
../rtl/IPs/spi_master.v
22+
../rtl/IPs/i2c_master.v
23+
../rtl/IPs/GPIO.v
24+
../rtl/IPs/APB_UART.v
25+
../rtl/IPs/APB_SPI.v
26+
../rtl/IPs/APB_I2C.v
27+
../dv/DFFRAM_beh.v
28+
../rtl/IPs/QSPI_XIP_CTRL.v
29+
../rtl/IPs/AHBSRAM.v
30+
../rtl/IPs/DFFRAM.v
31+
../rtl/IPs/DFFRAMBB.v
32+
+define+USE_DFFRAM_BEH=1
33+
../rtl/IPs/RAM_3Kx32.v
34+
../rtl/acc/AHB_SPM.v
35+
36+
+define+USE_DFFRAM_BEH=1
37+
../rtl/soc_core.v
38+
39+
../rtl/ibex/ibex_wrapper.v
40+
../rtl/ibex/ibex_alu.v
41+
../rtl/ibex/ibex_branch_predict.v
42+
../rtl/ibex/ibex_compressed_decoder.v
43+
../rtl/ibex/ibex_controller.v
44+
../rtl/ibex/ibex_core.v
45+
../rtl/ibex/ibex_counter.v
46+
../rtl/ibex/ibex_cs_registers.v
47+
../rtl/ibex/ibex_csr.v
48+
../rtl/ibex/ibex_decoder.v
49+
../rtl/ibex/ibex_dummy_instr.v
50+
../rtl/ibex/ibex_ex_block.v
51+
../rtl/ibex/ibex_fetch_fifo.v
52+
../rtl/ibex/ibex_icache.v
53+
../rtl/ibex/ibex_id_stage.v
54+
../rtl/ibex/ibex_if_stage.v
55+
../rtl/ibex/ibex_load_store_unit.v
56+
../rtl/ibex/ibex_multdiv_fast.v
57+
../rtl/ibex/ibex_multdiv_slow.v
58+
../rtl/ibex/ibex_pmp.v
59+
../rtl/ibex/ibex_prefetch_buffer.v
60+
../rtl/ibex/ibex_register_file_latch.v
61+
../rtl/ibex/ibex_wb_stage.v
62+
../rtl/ibex/prim_clock_gating.v
63+
../rtl/ibex/ibex_register_file_ff.v
64+
65+
66+
IBEX_SoC_TB.v
67+
sst26wf080b.v
68+
23LC512.v
69+
70+

openlane/Makefile

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
BLOCKS = $(shell find * -maxdepth 0 -type d)
2+
CONFIG = $(foreach block,$(BLOCKS), ./$(block)/config.tcl)
3+
CLEAN = $(foreach block,$(BLOCKS), clean-$(block))
4+
5+
OPENLANE_TAG ?= rc5
6+
OPENLANE_IMAGE_NAME ?= openlane:$(OPENLANE_TAG)
7+
OPENLANE_BASIC_COMMAND = "cd /project/openlane && flow.tcl -design ./$* -save_path .. -save -tag $* -overwrite"
8+
OPENLANE_INTERACTIVE_COMMAND = "cd /project/openlane && flow.tcl -it -file ./$*/interactive.tcl"
9+
10+
all: $(BLOCKS)
11+
12+
$(CONFIG) :
13+
@echo "Missing $@. Please create a configuration for that design"
14+
@exit 1
15+
16+
$(BLOCKS) : % : ./%/config.tcl FORCE
17+
ifeq ($(OPENLANE_ROOT),)
18+
@echo "Please export OPENLANE_ROOT"
19+
@exit 1
20+
endif
21+
ifeq ($(PDK_ROOT),)
22+
@echo "Please export PDK_ROOT"
23+
@exit 1
24+
endif
25+
@echo "###############################################"
26+
@sleep 1
27+
28+
@if [ -f ./$*/interactive.tcl ]; then\
29+
docker run -it -v $(OPENLANE_ROOT):/openLANE_flow \
30+
-v $(PDK_ROOT):$(PDK_ROOT) \
31+
-v $(PWD)/..:/project \
32+
-e PDK_ROOT=$(PDK_ROOT) \
33+
$(OPENLANE_IMAGE_NAME) sh -c $(OPENLANE_INTERACTIVE_COMMAND);\
34+
else\
35+
docker run -it -v $(OPENLANE_ROOT):/openLANE_flow \
36+
-v $(PDK_ROOT):$(PDK_ROOT) \
37+
-v $(PWD)/..:/project \
38+
-e PDK_ROOT=$(PDK_ROOT) \
39+
$(OPENLANE_IMAGE_NAME) sh -c $(OPENLANE_BASIC_COMMAND);\
40+
fi
41+
42+
.PHONY: openlane
43+
openlane:
44+
ifeq ($(OPENLANE_ROOT),)
45+
@echo "Please export OPENLANE_ROOT"
46+
@exit 1
47+
endif
48+
git clone https://github.com/efabless/openlane.git --branch=master $(OPENLANE_ROOT) && \
49+
cd $(OPENLANE_ROOT) && \
50+
make openlane
51+
52+
FORCE:
53+
54+
clean:
55+
@echo "Use clean_all to clean everything :)"
56+
57+
clean_all: $(CLEAN)
58+
59+
$(CLEAN): clean-% :
60+
rm -rf runs/$*
61+
rm -rf ../gds/$**
62+
rm -rf ../mag/$**
63+
rm -rf ../lef/$**

0 commit comments

Comments
 (0)