mirror of
https://github.com/handsomezhuzhu/2025-yatcpu.git
synced 2026-02-20 20:10:14 +00:00
updates Z7-10 for lab3 and lab4
This commit is contained in:
@@ -28,11 +28,15 @@ class Top(binaryFilename: String = "say_goodbye.asmbin") extends Module {
|
|||||||
|
|
||||||
val led = Output(Bool()) // z710 has few LEDs, use one for running indicator
|
val led = Output(Bool()) // z710 has few LEDs, use one for running indicator
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// original ref clock is 125MHz, divided in clock_control.v by 5 to avoid total negative slack too large
|
||||||
|
val clock_freq = 25_000_000
|
||||||
|
|
||||||
val mem = Module(new Memory(Parameters.MemorySizeInWords))
|
val mem = Module(new Memory(Parameters.MemorySizeInWords))
|
||||||
// val hdmi_display = Module(new HDMIDisplay)
|
// val hdmi_display = Module(new HDMIDisplay)
|
||||||
// val display = Module(new CharacterDisplay)
|
// val display = Module(new CharacterDisplay)
|
||||||
val timer = Module(new Timer)
|
val timer = Module(new Timer)
|
||||||
val uart = Module(new Uart(frequency = 32_000000, baudRate = 115200)) // 31M or 32M is good, 33M more error
|
val uart = Module(new Uart(frequency = clock_freq, baudRate = 115200)) // 31M or 32M is good, 33M more error
|
||||||
val dummy = Module(new Dummy)
|
val dummy = Module(new Dummy)
|
||||||
|
|
||||||
// display.io.bundle <> dummy.io.bundle
|
// display.io.bundle <> dummy.io.bundle
|
||||||
@@ -81,14 +85,13 @@ class Top(binaryFilename: String = "say_goodbye.asmbin") extends Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LED, blinks every second
|
// LED, blinks every second
|
||||||
val clock_freq = 40_000_000.U
|
|
||||||
val led_count = RegInit(0.U(32.W))
|
val led_count = RegInit(0.U(32.W))
|
||||||
when (led_count >= clock_freq) {
|
when (led_count >= clock_freq.U) {
|
||||||
led_count := 0.U
|
led_count := 0.U
|
||||||
}.otherwise {
|
}.otherwise {
|
||||||
led_count := led_count + 1.U
|
led_count := led_count + 1.U
|
||||||
}
|
}
|
||||||
io.led := (led_count >= (clock_freq >> 1))
|
io.led := (led_count >= (clock_freq.U >> 1))
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,25 @@
|
|||||||
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
// fpga4student.com: FPGA projects, VHDL projects, Verilog projects
|
||||||
// Company:
|
// Verilog project: Verilog code for clock divider on FPGA
|
||||||
// Engineer:
|
// Top level Verilog code for clock divider on FPGA
|
||||||
//
|
|
||||||
// Create Date: 2023/11/29 15:52:55
|
|
||||||
// Design Name:
|
|
||||||
// Module Name: clock_control
|
|
||||||
// Project Name:
|
|
||||||
// Target Devices:
|
|
||||||
// Tool Versions:
|
|
||||||
// Description:
|
|
||||||
//
|
|
||||||
// Dependencies:
|
|
||||||
//
|
|
||||||
// Revision:
|
|
||||||
// Revision 0.01 - File Created
|
|
||||||
// Additional Comments:
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
module clock_control(
|
module clock_control(
|
||||||
input clk_in,
|
input clock_in,
|
||||||
input enable_clk,
|
input enable_clk,
|
||||||
output clk_out
|
output reg clock_out
|
||||||
);
|
);
|
||||||
|
reg[3:0] counter = 4'd0;
|
||||||
// if clock is divided
|
parameter DIVISOR = 4'd5;
|
||||||
localparam clk_div = 2; // clock is diveded by half of divisor
|
// The frequency of the output clk_out
|
||||||
reg [3:0] cnt = 4'd0;
|
// = The frequency of the input clk_in divided by DIVISOR
|
||||||
reg out = 1'b0;
|
// For example: Fclk_in = 50Mhz, if you want to get 1Hz signal to blink LEDs
|
||||||
always @(posedge clk_in) begin
|
// You will modify the DIVISOR parameter value to 28'd50.000.000
|
||||||
cnt <= cnt + 4'd1;
|
// Then the frequency of the output clk_out = 50Mhz/50.000.000 = 1Hz
|
||||||
if (cnt >= (clk_div - 1)) begin
|
always @(posedge clock_in)
|
||||||
out <= ~out;
|
begin
|
||||||
cnt <= 0;
|
counter <= counter + 4'd1;
|
||||||
|
if(counter>=(DIVISOR-1)) begin
|
||||||
|
counter <= 4'd0;
|
||||||
end
|
end
|
||||||
|
clock_out <= ((counter<DIVISOR/2)?1'b1:1'b0) && enable_clk;
|
||||||
end
|
end
|
||||||
assign clk_out = out & enable_clk;
|
|
||||||
|
|
||||||
|
|
||||||
// original clock
|
|
||||||
// assign clk_out = clk_in & enable_clk;
|
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class Top(binaryFilename: String ="say_goodbye.asmbin") extends Module {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
val clock_freq = 100_000_000.U
|
val clock_freq = 125_000_000.U
|
||||||
|
|
||||||
val led_count = RegInit(0.U(32.W))
|
val led_count = RegInit(0.U(32.W))
|
||||||
when (led_count >= clock_freq) { // the led blinks every second, clock freq is 100M
|
when (led_count >= clock_freq) { // the led blinks every second, clock freq is 100M
|
||||||
|
|||||||
Reference in New Issue
Block a user