Add diagram, throw some code together
This commit is contained in:
107
doc/top.drawio
Normal file
107
doc/top.drawio
Normal file
@@ -0,0 +1,107 @@
|
||||
<mxfile host="Electron" modified="2023-09-08T06:35:22.343Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.2.8 Chrome/112.0.5615.165 Electron/24.2.0 Safari/537.36" etag="Vup8A8Ew0YNgsrP0aR2d" version="21.2.8" type="device">
|
||||
<diagram name="Page-1" id="W38x1XGtULFemG_pfs-W">
|
||||
<mxGraphModel dx="528" dy="362" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-1" value="65C02" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="400" y="470" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-2" value="" style="rounded=0;whiteSpace=wrap;html=1;strokeColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="560" y="400" width="410" height="300" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-3" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="560" y="440" width="130" height="120" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-4" value="Control Registers" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="595" y="450" width="60" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-8" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;strokeColor=#FF0000;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-5" target="qp9JQkSkVBdRz7zZg5ij-7">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-5" value="<font style="font-size: 8px;">M</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;" vertex="1" parent="1">
|
||||
<mxGeometry x="510" y="495" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;endArrow=none;endFill=0;strokeColor=#FF0000;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-7" target="qp9JQkSkVBdRz7zZg5ij-4">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="580" y="500" />
|
||||
<mxPoint x="580" y="470" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;endArrow=none;endFill=0;strokeColor=#FF0000;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-7" target="qp9JQkSkVBdRz7zZg5ij-9">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="580" y="500" />
|
||||
<mxPoint x="580" y="530" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-7" value="<font color="#ffffff" style="font-size: 8px;">S</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;fillColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="560" y="495" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-41" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeColor=#FF0000;endArrow=none;endFill=0;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-9" target="qp9JQkSkVBdRz7zZg5ij-40">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-9" value="MMU" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="595" y="510" width="60" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-18" value="Boot Rom" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="600" y="610" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-33" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;endArrow=none;endFill=0;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-19" target="qp9JQkSkVBdRz7zZg5ij-32">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-19" value="SDRAM" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="850" y="427.5" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-26" value="UART" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="850" y="520" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-28" value="<font color="#ffffff" style="font-size: 8px;">S</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;fillColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="710" y="635" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-29" value="<font color="#ffffff" style="font-size: 8px;">S</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;fillColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="850" y="545" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-30" value="<font color="#ffffff" style="font-size: 8px;">S</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;fillColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="850" y="452.5" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-32" value="SDRAM" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="1000" y="427.5" width="80" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-35" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="770" y="427.5" width="30" height="242.5" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-45" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;endArrow=none;endFill=0;strokeColor=#FF0000;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-36" target="qp9JQkSkVBdRz7zZg5ij-28">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-36" value="<font style="font-size: 8px;">M</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;" vertex="1" parent="1">
|
||||
<mxGeometry x="770" y="635" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-44" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;endArrow=none;endFill=0;strokeColor=#FF0000;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-37" target="qp9JQkSkVBdRz7zZg5ij-29">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-37" value="<font style="font-size: 8px;">M</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;" vertex="1" parent="1">
|
||||
<mxGeometry x="790" y="545" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-43" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;endArrow=none;endFill=0;strokeColor=#FF0000;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-38" target="qp9JQkSkVBdRz7zZg5ij-30">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-38" value="<font style="font-size: 8px;">M</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;" vertex="1" parent="1">
|
||||
<mxGeometry x="790" y="452.5" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-39" value="<font color="#ffffff" style="font-size: 8px;">S</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;fillColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="770" y="525" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-42" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;endArrow=none;endFill=0;strokeColor=#FF0000;" edge="1" parent="1" source="qp9JQkSkVBdRz7zZg5ij-40" target="qp9JQkSkVBdRz7zZg5ij-39">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="qp9JQkSkVBdRz7zZg5ij-40" value="<font style="font-size: 8px;">M</font>" style="whiteSpace=wrap;html=1;aspect=fixed;strokeColor=#FF0000;" vertex="1" parent="1">
|
||||
<mxGeometry x="680" y="525" width="10" height="10" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
@@ -1,6 +1,8 @@
|
||||
module addr_decode
|
||||
(
|
||||
input [15:0] i_addr,
|
||||
input [24:0] i_addr,
|
||||
|
||||
input config_reg_sel,
|
||||
|
||||
output o_rom_cs,
|
||||
output o_leds_cs,
|
||||
@@ -9,18 +11,16 @@ module addr_decode
|
||||
output o_divider_cs,
|
||||
output o_uart_cs,
|
||||
output o_spi_cs,
|
||||
output o_mapper_cs,
|
||||
output o_sdram_cs
|
||||
);
|
||||
|
||||
assign o_rom_cs = i_addr >= 16'hf000 && i_addr <= 16'hffff;
|
||||
assign o_timer_cs = i_addr >= 16'heff8 && i_addr <= 16'heffb;
|
||||
assign o_multiplier_cs = i_addr >= 16'heff0 && i_addr <= 16'heff7;
|
||||
assign o_divider_cs = i_addr >= 16'hefe8 && i_addr <= 16'hefef;
|
||||
assign o_uart_cs = i_addr >= 16'hefe6 && i_addr <= 16'hefe7;
|
||||
assign o_spi_cs = i_addr >= 16'hefd8 && i_addr <= 16'hefdb;
|
||||
assign o_mapper_cs = i_addr >= 16'hefb7 && i_addr <= 16'hefd7;
|
||||
assign o_leds_cs = i_addr == 16'hefff;
|
||||
assign o_sdram_cs = i_addr < 16'he000;
|
||||
assign o_rom_cs = (i_addr >= 25'hf000 && i_addr <= 25'hffff) && ~config_reg_sel;
|
||||
assign o_timer_cs = (i_addr >= 25'heff8 && i_addr <= 25'heffb) && ~config_reg_sel;
|
||||
assign o_multiplier_cs = (i_addr >= 25'heff0 && i_addr <= 25'heff7) && ~config_reg_sel;
|
||||
assign o_divider_cs = (i_addr >= 25'hefe8 && i_addr <= 25'hefef) && ~config_reg_sel;
|
||||
assign o_uart_cs = (i_addr >= 25'hefe6 && i_addr <= 25'hefe7) && ~config_reg_sel;
|
||||
assign o_spi_cs = (i_addr >= 25'hefd8 && i_addr <= 25'hefdb) && ~config_reg_sel;
|
||||
assign o_leds_cs = (i_addr == 25'hefff) && ~config_reg_sel;
|
||||
assign o_sdram_cs = (i_addr < 25'he000 || i_addr >= 25'h10000) && ~config_reg_sel;
|
||||
|
||||
endmodule
|
||||
19
hw/efinix_fpga/control_registers.sv
Normal file
19
hw/efinix_fpga/control_registers.sv
Normal file
@@ -0,0 +1,19 @@
|
||||
module control_registers #(
|
||||
parameter START = 16'h0a00,
|
||||
parameter SIZE = 16'h0600
|
||||
)(
|
||||
input i_clk,
|
||||
input i_rst,
|
||||
|
||||
input logic o_selected,
|
||||
input i_rwb,
|
||||
input [15:0] i_addr,
|
||||
input [7:0] i_data,
|
||||
output logic [7:0] o_data
|
||||
);
|
||||
|
||||
logic [7:0] regs [SIZE];
|
||||
|
||||
assign o_selected = (addr >= START && addr > START + SIZE);
|
||||
|
||||
endmodule
|
||||
@@ -1,4 +1,8 @@
|
||||
module super6502
|
||||
#(
|
||||
parameter CONTROL_REG_START = 16'h0a00,
|
||||
parameter CONTROL_REG_SIZE = 16'h0600
|
||||
)
|
||||
(
|
||||
input logic i_sysclk, // Controller Clock (100MHz)
|
||||
input logic i_sdrclk, // t_su and t_wd clock (200MHz)
|
||||
@@ -71,6 +75,14 @@ always @(posedge clk_2) begin
|
||||
end
|
||||
end
|
||||
|
||||
logic w_control_reg_cs;
|
||||
|
||||
|
||||
// 0a00 - 0xffff
|
||||
assign w_control_reg_cs = (cpu_addr >= CONTROL_REG_START && cpu_addr < CONTROL_REG_START + CONTROL_REG_SIZE);
|
||||
|
||||
// The w_control_reg_cs is redundant but whatever
|
||||
assign o_mapper_cs = (cpu_addr >= 16'h0a00 && cpu_addr <= 25'h0a20) && w_control_reg_cs;
|
||||
|
||||
logic w_rom_cs;
|
||||
logic w_leds_cs;
|
||||
@@ -83,7 +95,8 @@ logic w_mapper_cs;
|
||||
logic w_spi_cs;
|
||||
|
||||
addr_decode u_addr_decode(
|
||||
.i_addr(cpu_addr),
|
||||
.i_addr(w_sdram_addr),
|
||||
.config_reg_sel(w_control_reg_cs),
|
||||
.o_rom_cs(w_rom_cs),
|
||||
.o_leds_cs(w_leds_cs),
|
||||
.o_timer_cs(w_timer_cs),
|
||||
@@ -91,7 +104,6 @@ addr_decode u_addr_decode(
|
||||
.o_divider_cs(w_divider_cs),
|
||||
.o_uart_cs(w_uart_cs),
|
||||
.o_spi_cs(w_spi_cs),
|
||||
.o_mapper_cs(w_mapper_cs),
|
||||
.o_sdram_cs(w_sdram_cs)
|
||||
);
|
||||
|
||||
@@ -128,8 +140,21 @@ always_comb begin
|
||||
cpu_data_out = 'x;
|
||||
end
|
||||
|
||||
logic [24:0] w_sdram_addr;
|
||||
|
||||
mapper u_mapper(
|
||||
.clk(clk_2),
|
||||
.rst(~cpu_resb),
|
||||
.cpu_addr(cpu_addr),
|
||||
.sdram_addr(w_sdram_addr),
|
||||
.cs(w_mapper_cs),
|
||||
.rwb(cpu_rwb),
|
||||
.i_data(cpu_data_in),
|
||||
.o_data(w_mapper_data_out)
|
||||
);
|
||||
|
||||
rom #(.DATA_WIDTH(8), .ADDR_WIDTH(12)) u_rom(
|
||||
.addr(cpu_addr[11:0]),
|
||||
.addr(w_sdram_addr[11:0]),
|
||||
.clk(clk_2),
|
||||
.data(w_rom_data_out)
|
||||
);
|
||||
@@ -152,7 +177,7 @@ timer u_timer(
|
||||
.o_data(w_timer_data_out),
|
||||
.cs(w_timer_cs),
|
||||
.rwb(cpu_rwb),
|
||||
.addr(cpu_addr[1:0]),
|
||||
.addr(w_sdram_addr[1:0]),
|
||||
.irqb(w_timer_irqb)
|
||||
);
|
||||
|
||||
@@ -163,7 +188,7 @@ multiplier u_multiplier(
|
||||
.o_data(w_multiplier_data_out),
|
||||
.cs(w_multiplier_cs),
|
||||
.rwb(cpu_rwb),
|
||||
.addr(cpu_addr[2:0])
|
||||
.addr(w_sdram_addr[2:0])
|
||||
);
|
||||
|
||||
divider_wrapper u_divider(
|
||||
@@ -174,7 +199,7 @@ divider_wrapper u_divider(
|
||||
.o_data(w_divider_data_out),
|
||||
.cs(w_divider_cs),
|
||||
.rwb(cpu_rwb),
|
||||
.addr(cpu_addr[2:0])
|
||||
.addr(w_sdram_addr[2:0])
|
||||
);
|
||||
|
||||
logic w_uart_irqb;
|
||||
@@ -187,7 +212,7 @@ uart_wrapper u_uart(
|
||||
.o_data(w_uart_data_out),
|
||||
.cs(w_uart_cs),
|
||||
.rwb(cpu_rwb),
|
||||
.addr(cpu_addr[0]),
|
||||
.addr(w_sdram_addr[0]),
|
||||
.rx_i(uart_rx),
|
||||
.tx_o(uart_tx),
|
||||
.irqb(w_uart_irqb)
|
||||
@@ -198,7 +223,7 @@ spi_controller spi_controller(
|
||||
.i_rst(~cpu_resb),
|
||||
.i_cs(w_spi_cs),
|
||||
.i_rwb(cpu_rwb),
|
||||
.i_addr(cpu_addr[1:0]),
|
||||
.i_addr(w_sdram_addr[1:0]),
|
||||
.i_data(cpu_data_in),
|
||||
.o_data(w_spi_data_out),
|
||||
|
||||
@@ -208,19 +233,6 @@ spi_controller spi_controller(
|
||||
.i_spi_miso(spi_miso)
|
||||
);
|
||||
|
||||
logic [24:0] w_sdram_addr;
|
||||
|
||||
mapper u_mapper(
|
||||
.clk(clk_2),
|
||||
.rst(~cpu_resb),
|
||||
.cpu_addr(cpu_addr),
|
||||
.sdram_addr(w_sdram_addr),
|
||||
.cs(w_mapper_cs),
|
||||
.rwb(cpu_rwb),
|
||||
.i_data(cpu_data_in),
|
||||
.o_data(w_mapper_data_out)
|
||||
);
|
||||
|
||||
|
||||
sdram_adapter u_sdram_adapter(
|
||||
.i_cpuclk(clk_2),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<efx:project name="super6502" description="" last_change_date="Wed September 6 2023 20:09:59" location="/home/byron/ServerProjects/super6502/hw/efinix_fpga" sw_version="2022.2.322" last_run_state="pass" last_run_tool="efx_map" last_run_flow="syn" config_result_in_sync="true" design_ood="sync" place_ood="sync" route_ood="sync" xmlns:efx="http://www.efinixinc.com/enf_proj" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.efinixinc.com/enf_proj enf_proj.xsd">
|
||||
<efx:project name="super6502" description="" last_change_date="Thu September 7 2023 19:23:34" location="/home/byron/ServerProjects/super6502/hw/efinix_fpga" sw_version="2022.2.322" last_run_state="pass" last_run_tool="efx_pgm" last_run_flow="bitstream" config_result_in_sync="true" design_ood="sync" place_ood="sync" route_ood="sync" xmlns:efx="http://www.efinixinc.com/enf_proj" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.efinixinc.com/enf_proj enf_proj.xsd">
|
||||
<efx:device_info>
|
||||
<efx:family name="Trion"/>
|
||||
<efx:device name="T20F256"/>
|
||||
|
||||
Reference in New Issue
Block a user