You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hello.
it would be cool if myHDL could support multi-dimensional signals. this helps coding things like matrix multiplication, convolution etc easier.
suppose this architecture that I am going to talk about:
frommyhdlimport*size=16data_width=32@blockdefarr(clk, rst):
# Flattened memory and registers with proper type initializationmem= [[Signal(intbv(0)[data_width:]) for_inrange(size)] for_inrange(size)]
@always(clk.posedge)deflogic():
ifrst:
foriinrange(size):
forjinrange(size):
mem[i][j].next=0returnlogic
when coding the matrix multiplier, one can index the signal by each index. the same is true for reduction on a given dimension of a matrix, doing broadcasting easier, etc.
with this way, one can even implement tensor operations in myHDL and then transform it into verilog/vhdl.
The text was updated successfully, but these errors were encountered:
I am working on a new converter approach and I - accidentally :) - added initial support for a true multidimensional Array MyHDL object.
The double levelLisOfSignals as you propose is too tedious and (IMO quite important) utterly un-beautiful
I kept the functionality simple on purpose.
Note that logic is a SystemVerilog reserved keyword Reset is a MyHDL ResetSignal; using it in an always_seq decorator will infer the necessary logic to reset (all) used output variables.
Output:
// File: kernel.sv// Source: C:\myhdlsupport\myhdl\myhdl\test\development\b_e.py// Generated by MyHDL 0.12.1// Date: 2025-04-14 10:24:59 UTC`timescale1ns/10psmodulekernel (
inputlogic Clk,
inputlogic Reset,
inputlogic [8-1:0] D [0:3-1],
inputlogic ValidIn,
output logic [8-1:0] K [0:3-1][0:3-1],
outputlogic ValidOut
);
always_ff@(posedge Clk) begin:synch integer j;
integer i;
if (Reset ==1) begin
ValidOut <=0;
K<='{'{1, 2, 3}, '{4, 5, 6}, '{7, 8, 9}};
endelsebegin
ValidOut <= ValidIn;
if (ValidIn) beginfor (j =1; j <3; j = j +1) beginK[j] <=K[(j -1)];
endfor (i =0; i <3; i = i +1) beginK[0][i] <=D[i];
endendendend:synchendmodule
You can have a peek at my branch: https://github.com/josyb/myhdl/tree/new_converter
It currently only supports conversion to SystemVerilog - unfortunately the Icarus Verilog simulator only supports little of SystemVerilog so the example above will not pass, but the Sigasi linter doesn't complain.
hello.
it would be cool if myHDL could support multi-dimensional signals. this helps coding things like matrix multiplication, convolution etc easier.
suppose this architecture that I am going to talk about:
when coding the matrix multiplier, one can index the signal by each index. the same is true for reduction on a given dimension of a matrix, doing broadcasting easier, etc.
with this way, one can even implement tensor operations in myHDL and then transform it into verilog/vhdl.
The text was updated successfully, but these errors were encountered: