Forum Discussion
How to force manually in ModelSim one dada bus with value like sin(x)
- 1 year ago
In that case, you may create a module for the sine function:
module sine_generator (
input wire clk,
input wire reset,
output reg signed [10:0] sine_out
);
reg [6:0] index; // 7-bit index for 128 samples
reg signed [10:0] sine_lut [0:127]; // 128-point lookup table
initial begin
// Precompute sine values and load them into the LUT
sine_lut[0] = 0;
sine_lut[1] = 50;
sine_lut[2] = 100;
sine_lut[3] = 150;
sine_lut[4] = 200;
sine_lut[5] = 250;
// ... (continue with the full sine wave values up to 127)
sine_lut[127] = -50;
end
always @(posedge clk or posedge reset) begin
if (reset) begin
index <= 0;
sine_out <= 0;
end else begin
sine_out <= sine_lut[index]; // Output the sine value
index <= index + 1; // Increment index for next sample
end
end
endmodule
I’m glad that your question has been addressed, I now transition this thread to community support. If you have a new question, Please login to ‘https://supporttickets.intel.com/s/?language=en_US’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.