-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive progress on both the CPU and the peripherals
- Loading branch information
1 parent
3af0802
commit 812aa62
Showing
38 changed files
with
1,115 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
// Copyright © 2023, Julian Scheffers, see LICENSE for more information | ||
|
||
`timescale 1ns/1ps | ||
|
||
|
||
|
||
// A PWM generator intended for use with GPIO signals. | ||
module boa_peri_pwm#( | ||
// Base address to respond to. | ||
parameter addr = 32'h8000_0000 | ||
)( | ||
// CPU clock. | ||
input logic clk, | ||
// PWM clock. | ||
input logic pwm_clk, | ||
// Synchronous reset. | ||
input logic rst, | ||
|
||
// Peripheral bus. | ||
boa_mem_bus.MEM bus, | ||
|
||
// PWM value. | ||
output logic pwm | ||
); | ||
// Configuration register. | ||
logic[31:0] cfg; | ||
boa_peri_writeable#(addr) cfg_reg(clk, rst, bus, cfg); | ||
wire[7:0] pwm_val = cfg[7:0]; | ||
wire[15:0] pwm_div = cfg[31:15]; | ||
|
||
// PWM generator. | ||
logic[15:0] div = 1; | ||
logic[7:0] val; | ||
always @(posedge pwm_clk) begin | ||
if (div == 1) begin | ||
div <= pwm_div ? pwm_div : 1; | ||
val <= val + 1; | ||
if (val == 0) begin | ||
pwm <= pwm_val != 0; | ||
end else if (val == pwm_val) begin | ||
pwm <= 0; | ||
end | ||
end else begin | ||
div <= div - 1; | ||
end | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
// Copyright © 2023, Julian Scheffers, see LICENSE for more information | ||
|
||
`timescale 1ns/1ps | ||
|
||
|
||
|
||
// A single word of read-only MMIO. | ||
module boa_peri_readable#( | ||
// Base address to respond to. | ||
parameter addr = 32'h8000_0000 | ||
)( | ||
// CPU clock. | ||
input logic clk, | ||
// Synchronous reset. | ||
input logic rst, | ||
|
||
// Peripheral bus. | ||
boa_mem_bus.MEM bus, | ||
|
||
// Value to present to the bus. | ||
input logic[31:0] value | ||
); | ||
assign bus.ready = 1; | ||
always @(posedge clk) begin | ||
if (bus.addr == addr[bus.alen-1:2]) begin | ||
bus.rdata <= value; | ||
end else begin | ||
bus.rdata <= 0; | ||
end | ||
end | ||
endmodule |
Oops, something went wrong.