Change divider to pipelined version
The pipelining allows the cpu to run at a faster clock speed but results in latency. At the current 2 MHz, there is 1 cycle of latency which is negligible because the 6502 cannot do sequential data memory accesses. In the future, there will have to be some sort of status flag or interrupt showing that the divider is ready.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
|||||||
module divider_wrapper(
|
module divider_wrapper(
|
||||||
input clk,
|
input clk,
|
||||||
|
input divclk,
|
||||||
input reset,
|
input reset,
|
||||||
input [7:0] i_data,
|
input [7:0] i_data,
|
||||||
output logic [7:0] o_data,
|
output logic [7:0] o_data,
|
||||||
@@ -11,6 +12,8 @@ module divider_wrapper(
|
|||||||
logic [15:0] numer, denom;
|
logic [15:0] numer, denom;
|
||||||
logic [15:0] quotient, remain;
|
logic [15:0] quotient, remain;
|
||||||
|
|
||||||
|
logic [15:0] r_quotient, r_remain;
|
||||||
|
|
||||||
logic clken, rfd;
|
logic clken, rfd;
|
||||||
|
|
||||||
assign clken = '1;
|
assign clken = '1;
|
||||||
@@ -20,7 +23,7 @@ divider u_divider(
|
|||||||
.numer ( numer ),
|
.numer ( numer ),
|
||||||
.denom ( denom ),
|
.denom ( denom ),
|
||||||
.clken ( clken ),
|
.clken ( clken ),
|
||||||
.clk ( clk ),
|
.clk ( divclk ),
|
||||||
.reset ( reset ),
|
.reset ( reset ),
|
||||||
.quotient ( quotient ),
|
.quotient ( quotient ),
|
||||||
.remain ( remain ),
|
.remain ( remain ),
|
||||||
@@ -56,23 +59,30 @@ always_ff @(negedge clk) begin
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
always_ff @(posedge divclk) begin
|
||||||
|
if (rfd) begin
|
||||||
|
r_quotient <= quotient;
|
||||||
|
r_remain <= remain;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
always_comb begin
|
always_comb begin
|
||||||
|
|
||||||
case (addr)
|
case (addr)
|
||||||
3'h4: begin
|
3'h4: begin
|
||||||
o_data = quotient[7:0];
|
o_data = r_quotient[7:0];
|
||||||
end
|
end
|
||||||
|
|
||||||
3'h5: begin
|
3'h5: begin
|
||||||
o_data = quotient[15:8];
|
o_data = r_quotient[15:8];
|
||||||
end
|
end
|
||||||
|
|
||||||
3'h6: begin
|
3'h6: begin
|
||||||
o_data = remain[7:0];
|
o_data = r_remain[7:0];
|
||||||
end
|
end
|
||||||
|
|
||||||
3'h7: begin
|
3'h7: begin
|
||||||
o_data = remain[15:8];
|
o_data = r_remain[15:8];
|
||||||
end
|
end
|
||||||
|
|
||||||
endcase
|
endcase
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
`define IP_UUID _1d82aa757d4b4554a855552eadc85243
|
`define IP_UUID _e54826097db04c8995c0c56653e54765
|
||||||
`define IP_NAME_CONCAT(a,b) a``b
|
`define IP_NAME_CONCAT(a,b) a``b
|
||||||
`define IP_MODULE_NAME(name) `IP_NAME_CONCAT(name,`IP_UUID)
|
`define IP_MODULE_NAME(name) `IP_NAME_CONCAT(name,`IP_UUID)
|
||||||
module divider (
|
module divider (
|
||||||
@@ -62,7 +62,7 @@ output rfd
|
|||||||
.WIDTHD (16),
|
.WIDTHD (16),
|
||||||
.DREPRESENTATION ("UNSIGNED"),
|
.DREPRESENTATION ("UNSIGNED"),
|
||||||
.PIPELINE (0),
|
.PIPELINE (0),
|
||||||
.LATENCY (0)
|
.LATENCY (16)
|
||||||
) u_divider(
|
) u_divider(
|
||||||
.numer ( numer ),
|
.numer ( numer ),
|
||||||
.denom ( denom ),
|
.denom ( denom ),
|
||||||
|
|||||||
@@ -48,4 +48,4 @@ localparam WIDTHN = 16;
|
|||||||
localparam WIDTHD = 16;
|
localparam WIDTHD = 16;
|
||||||
localparam DREPRESENTATION = "UNSIGNED";
|
localparam DREPRESENTATION = "UNSIGNED";
|
||||||
localparam PIPELINE = 0;
|
localparam PIPELINE = 0;
|
||||||
localparam LATENCY = 0;
|
localparam LATENCY = 16;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"WIDTHD": "16",
|
"WIDTHD": "16",
|
||||||
"DREPRESENTATION": "0",
|
"DREPRESENTATION": "0",
|
||||||
"PIPELINE": "0",
|
"PIPELINE": "0",
|
||||||
"LATENCY": "0"
|
"LATENCY": "16"
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"external_source_source": [
|
"external_source_source": [
|
||||||
@@ -29,5 +29,5 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sw_version": "2022.2.322",
|
"sw_version": "2022.2.322",
|
||||||
"generated_date": "2023-01-05T22:36:48.178317"
|
"generated_date": "2023-01-05T23:44:10.084005"
|
||||||
}
|
}
|
||||||
@@ -149,6 +149,7 @@ multiplier u_multiplier(
|
|||||||
|
|
||||||
divider_wrapper u_divider(
|
divider_wrapper u_divider(
|
||||||
.clk(clk_2),
|
.clk(clk_2),
|
||||||
|
.divclk(clk_50),
|
||||||
.reset(~cpu_resb),
|
.reset(~cpu_resb),
|
||||||
.i_data(cpu_data_in),
|
.i_data(cpu_data_in),
|
||||||
.o_data(w_divider_data_out),
|
.o_data(w_divider_data_out),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<efx:project name="super6502" description="" last_change_date="Thu January 5 2023 18:30:12" location="/home/byron/Projects/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:project name="super6502" description="" last_change_date="Thu January 5 2023 19:19:10" location="/home/byron/Projects/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:device_info>
|
||||||
<efx:family name="Trion"/>
|
<efx:family name="Trion"/>
|
||||||
<efx:device name="T20F256"/>
|
<efx:device name="T20F256"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user