Fast version of Oberon RISC5 for Pepino
One outcome of the discussion about the Oberon RISC5 verilog code is that I did a deeper study about the clock limits for the project and found that the RISC5 CPU in itself can be clocked at up to about 66 MHz but the external SRAM path is too slow for that speed (read is the problem). The asynchronous nature of the SRAM interface makes it hard to constrain the ISE compiler to work hard on this path. I did trace the SRAM read data path and found that it takes about 10 ns from the SRAM data input pins to the Z register bit (this is the longest path). The address output path is about 5 nS and with a 10 nS SRAM access time the fastest system clock cycle should be around 25 nS. To test this out I created a version of the code that runs the CPU at 37.5 MHz (26.666 nS) instead of 25 MHz, i.e. the CPU is running 1/2 the video clock rate instead of 1/3, and it seems to run fine of both the LX9 and the LX25 version of Pepino. All timing constants (UART Rx, UART Tx, SPI and millisecond timer) have been changed to reflect the 50% faster clock rate. If anyone want to try it, the project (including bit files) is available here: https://github.com/Saanlima/Pepino/tree/master/Projects/RISC5Verilog_Pepino_... Cheers, Magnus
Walter Magnus rewrote the clock generation according to your recommendation to use DCMs for clock generation and not general logic circuitery. One question as I'm not at all an expert with clocks: If I look at the FPGA sources of the RS232 drivers, I still find the method that the clock to drive the RS232 is generated by dividing the clk with "normal" circuitery. Would that be okay for you? Or in other words: why might it be okay there but not for SRAM access? br Jörg
Am 26.02.2016 um 18:59 schrieb Magnus Karlsson <magnus@saanlima.com>:
One outcome of the discussion about the Oberon RISC5 verilog code is that I did a deeper study about the clock limits for the project and found that the RISC5 CPU in itself can be clocked at up to about 66 MHz but the external SRAM path is too slow for that speed (read is the problem). The asynchronous nature of the SRAM interface makes it hard to constrain the ISE compiler to work hard on this path.
I did trace the SRAM read data path and found that it takes about 10 ns from the SRAM data input pins to the Z register bit (this is the longest path). The address output path is about 5 nS and with a 10 nS SRAM access time the fastest system clock cycle should be around 25 nS.
To test this out I created a version of the code that runs the CPU at 37.5 MHz (26.666 nS) instead of 25 MHz, i.e. the CPU is running 1/2 the video clock rate instead of 1/3, and it seems to run fine of both the LX9 and the LX25 version of Pepino. All timing constants (UART Rx, UART Tx, SPI and millisecond timer) have been changed to reflect the 50% faster clock rate.
If anyone want to try it, the project (including bit files) is available here: https://github.com/Saanlima/Pepino/tree/master/Projects/RISC5Verilog_Pepino_...
Cheers, Magnus -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
No, those are not clocks. A clock signal is a signal that is used in a /always @(posedge clk)/ statement or directly connected to the clock input of a clocked element (like flip-flops and BRAM etc.). In the RS232 code the clocked elements are all clocked using the 25 MHz clock but the clock is only acted upon when the baud-rate counter indicates that it's time to shift out the next bit. This is how you typically create a slower "clock" in a synchronous system - you clock all sequential elements with the same clock but only enable the slower running elements when it's time to act on the clock. Magnus On 2/27/2016 6:29 AM, Jörg Straube wrote:
Walter
Magnus rewrote the clock generation according to your recommendation to use DCMs for clock generation and not general logic circuitery. One question as I'm not at all an expert with clocks: If I look at the FPGA sources of the RS232 drivers, I still find the method that the clock to drive the RS232 is generated by dividing the clk with "normal" circuitery. Would that be okay for you? Or in other words: why might it be okay there but not for SRAM access?
br Jörg
Am 26.02.2016 um 18:59 schrieb Magnus Karlsson <magnus@saanlima.com>:
One outcome of the discussion about the Oberon RISC5 verilog code is that I did a deeper study about the clock limits for the project and found that the RISC5 CPU in itself can be clocked at up to about 66 MHz but the external SRAM path is too slow for that speed (read is the problem). The asynchronous nature of the SRAM interface makes it hard to constrain the ISE compiler to work hard on this path.
I did trace the SRAM read data path and found that it takes about 10 ns from the SRAM data input pins to the Z register bit (this is the longest path). The address output path is about 5 nS and with a 10 nS SRAM access time the fastest system clock cycle should be around 25 nS.
To test this out I created a version of the code that runs the CPU at 37.5 MHz (26.666 nS) instead of 25 MHz, i.e. the CPU is running 1/2 the video clock rate instead of 1/3, and it seems to run fine of both the LX9 and the LX25 version of Pepino. All timing constants (UART Rx, UART Tx, SPI and millisecond timer) have been changed to reflect the 50% faster clock rate.
If anyone want to try it, the project (including bit files) is available here: https://github.com/Saanlima/Pepino/tree/master/Projects/RISC5Verilog_Pepino_...
Cheers, Magnus -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Jörg In FPGA a clock signal is a signal that toggle the output of a register but not the signal that enable to toggle. Trying to clarify the statement, the D or CE input of a FF can't change the Q output by itself. Is the clock edge of interest that toggle Q according to D and CE. This allow toggling all registers between clock skew boundaries. As the implementation tool know clock distribution tree skew, PAR try to place and route the design to respect setup and hold time of all registers at component operational limits. So, generate a baud rate with a counter and use this counter as CE of UART registers if safe. Walter On 2/27/2016 6:29 AM, Jörg Straube wrote:
Walter
Magnus rewrote the clock generation according to your recommendation to use DCMs for clock generation and not general logic circuitery. One question as I'm not at all an expert with clocks: If I look at the FPGA sources of the RS232 drivers, I still find the method that the clock to drive the RS232 is generated by dividing the clk with "normal" circuitery. Would that be okay for you? Or in other words: why might it be okay there but not for SRAM access?
br Jörg
The current RISC5 verilog code does not take advantage of the fact the both Spartan3 and Spartan6 have hardware multipliers but instead does the multiply by doing 16 additions, which will case the CPU to stall for 16 clocks for each multiplication. As a test I rewrote the multiplier code so that the built-in hardware multipliers are used instead, and with this code the CPU is only stalled for 1 clock instead of 16 clocks. The code uses the verilog2001 syntax to specify a signed and an unsigned multiplier, and the u input signal determines if the unsigned or signed result is used. This make the code in my opinion easier to understand compared to the current adder-based code. Here is the code: `timescale 1ns / 1ps // MK 29.2.2016 module Multiplier( input clk, run, u, output stall, input [31:0] x, y, output [63:0] z); wire [63:0] z_signed, z_unsigned; reg [63:0] P; reg S; assign z = P; assign stall = run & ~S; mult_signed (.x(x), .y(y), .z(z_signed)); mult_unsigned (.x(x), .y(y), .z(z_unsigned)); always @ (posedge(clk)) begin P <= u ? z_unsigned : z_signed; S <= run; end endmodule module mult_signed ( input signed [31:0] x, input signed [31:0] y, output signed [63:0] z); assign z = x * y; endmodule module mult_unsigned ( input [31:0] x, input [31:0] y, output [63:0] z); assign z = x * y; endmodule This version of the code have succesfully been tested on Pepino board. Cheers, Magnus On 2/26/2016 9:59 AM, Magnus Karlsson wrote:
One outcome of the discussion about the Oberon RISC5 verilog code is that I did a deeper study about the clock limits for the project and found that the RISC5 CPU in itself can be clocked at up to about 66 MHz but the external SRAM path is too slow for that speed (read is the problem). The asynchronous nature of the SRAM interface makes it hard to constrain the ISE compiler to work hard on this path.
I did trace the SRAM read data path and found that it takes about 10 ns from the SRAM data input pins to the Z register bit (this is the longest path). The address output path is about 5 nS and with a 10 nS SRAM access time the fastest system clock cycle should be around 25 nS.
To test this out I created a version of the code that runs the CPU at 37.5 MHz (26.666 nS) instead of 25 MHz, i.e. the CPU is running 1/2 the video clock rate instead of 1/3, and it seems to run fine of both the LX9 and the LX25 version of Pepino. All timing constants (UART Rx, UART Tx, SPI and millisecond timer) have been changed to reflect the 50% faster clock rate.
If anyone want to try it, the project (including bit files) is available here: https://github.com/Saanlima/Pepino/tree/master/Projects/RISC5Verilog_Pepino_...
Cheers, Magnus -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2/29/2016 4:00 PM, Magnus Karlsson wrote: Sorry, I meant 32 clocks for the multiply, not 16 clocks. Magnus
The current RISC5 verilog code does not take advantage of the fact the both Spartan3 and Spartan6 have hardware multipliers but instead does the multiply by doing 32 additions, which will cause the CPU to stall for 32 clocks for each multiplication.
As a test I rewrote the multiplier code so that the built-in hardware multipliers are used instead, and with this code the CPU is only stalled for 1 clock instead of 32 clocks. The code uses the verilog2001 syntax to specify a signed and an unsigned multiplier, and the u input signal determines if the unsigned or signed result is used. This make the code in my opinion easier to understand compared to the current adder-based code.
Here is the code:
`timescale 1ns / 1ps // MK 29.2.2016
module Multiplier( input clk, run, u, output stall, input [31:0] x, y, output [63:0] z);
wire [63:0] z_signed, z_unsigned; reg [63:0] P; reg S;
assign z = P; assign stall = run & ~S;
mult_signed (.x(x), .y(y), .z(z_signed)); mult_unsigned (.x(x), .y(y), .z(z_unsigned));
always @ (posedge(clk)) begin P <= u ? z_unsigned : z_signed; S <= run; end
endmodule
module mult_signed ( input signed [31:0] x, input signed [31:0] y, output signed [63:0] z);
assign z = x * y;
endmodule
module mult_unsigned ( input [31:0] x, input [31:0] y, output [63:0] z);
assign z = x * y;
endmodule
This version of the code have succesfully been tested on Pepino board.
Cheers, Magnus
On 2/26/2016 9:59 AM, Magnus Karlsson wrote:
One outcome of the discussion about the Oberon RISC5 verilog code is that I did a deeper study about the clock limits for the project and found that the RISC5 CPU in itself can be clocked at up to about 66 MHz but the external SRAM path is too slow for that speed (read is the problem). The asynchronous nature of the SRAM interface makes it hard to constrain the ISE compiler to work hard on this path.
I did trace the SRAM read data path and found that it takes about 10 ns from the SRAM data input pins to the Z register bit (this is the longest path). The address output path is about 5 nS and with a 10 nS SRAM access time the fastest system clock cycle should be around 25 nS.
To test this out I created a version of the code that runs the CPU at 37.5 MHz (26.666 nS) instead of 25 MHz, i.e. the CPU is running 1/2 the video clock rate instead of 1/3, and it seems to run fine of both the LX9 and the LX25 version of Pepino. All timing constants (UART Rx, UART Tx, SPI and millisecond timer) have been changed to reflect the 50% faster clock rate.
If anyone want to try it, the project (including bit files) is available here: https://github.com/Saanlima/Pepino/tree/master/Projects/RISC5Verilog_Pepino_...
Cheers, Magnus -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
participants (3)
-
Jörg Straube -
Magnus Karlsson -
Walter