Skip to content

Instantly share code, notes, and snippets.

View Wren6991's full-sized avatar

Luke Wren Wren6991

  • Cambridge, UK
View GitHub Profile
module wallace_adder #(
parameter W = 32, // valid for W >= 1
parameter N = 3 // valid for N >= 3
) (
input wire [W*N-1:0] in,
output wire [W-1:0] out
);
generate
if (N == 3) begin: base
module wallace_mult #(
parameter W = 32
) (
input wire sext_a,
input wire sext_b,
input wire [W-1:0] a,
input wire [W-1:0] b,
output wire [W*2-1:0] out
);
module tb();
localparam W = 29;
localparam TEST_LEN = 10000;
reg [W-1:0] a;
reg [W-1:0] b;
wire [W*2-1:0] out;
wallace_mult #(.W(W)) inst_radix2_mult (.sext_a(1'b0), .sext_b(1'b0), .a(a), .b(b), .out(out));
module tb();
localparam W = 29;
localparam TEST_LEN = 10000;
reg [W-1:0] a;
reg [W-1:0] b;
wire [W*2-1:0] out;
wallace_mult #(.W(W)) inst_radix2_mult (.sext_a(1'b0), .sext_b(1'b0), .a(a), .b(b), .out(out));
module riscboy_fpga #(
parameter PRELOAD_FILE = "bootram_init32.hex"
) (
input wire clk_osc,
output wire [7:0] led
);
`include "gpio_pinmap.vh"
// Clock + Reset resources
module tmds_encode (
input wire clk,
input wire rst_n,
input wire [1:0] c,
input wire [7:0] d,
input wire den,
output reg [9:0] q
);
.syntax unified
.cpu cortex-m0plus
.thumb
#ifndef FONT_BLIT_UNROLL
#define FONT_BLIT_UNROLL 4
#endif
.macro decl_func name
.global \name
@Wren6991
Wren6991 / bug.ys
Created August 23, 2020 15:18
hazard5_alu CXXRTL repro
read_verilog hazard5_alu.v hazard5_shift_barrel.v
write_cxxrtl foo.cpp
module priority_select #(
parameter N = 16 // any positive integer
) (
input wire [N-1:0] req,
output wire [N-1:0] gnt
);
generate
if (N == 1) begin: base_case0
assign gnt = req;

RISCBoy Audio Processing Unit (APU)

Goals:

  • Resource budget: 100 LUTs (excluding system interface and digital DACs), two BRAMs
  • 48 kHz 8 bit stereo output when running at 36 MHz
  • Provide similar capability to an original Gameboy with default microcode
  • Be rather more capable with user-supplied microcode
  • Easy to use as a dumb wave-out ring buffer interface
  • Fun to program