Dsptools examples (#457)
* Add c test files for DSPTools example * Update tests Makefile to build DSPTools c tests * Add DSPTools example configs to ConfigMixins and RocketConfigs * Add dsptools and rocket-dsptools as dependancies for example * Add Scala implementations of DSPTools test blocks * Clean up GenericFIR scala * Modify dsptools blocks and mixins to match 'CanHave' when adding peripherial * Update documentation, will need reworking once FIR is characterized as fixed point * Update naming of Passthrough to Streaming Passthrough. Update naming of Thing to Chain and remove old Chain * Fix capitalization in docs (#419) * Add c test files for DSPTools example * Update tests Makefile to build DSPTools c tests * Add DSPTools example configs to ConfigMixins and RocketConfigs * Add dsptools and rocket-dsptools as dependancies for example * Add Scala implementations of DSPTools test blocks * Clean up GenericFIR scala * Modify dsptools blocks and mixins to match 'CanHave' when adding peripherial * Update documentation, will need reworking once FIR is characterized as fixed point * Update naming of Passthrough to Streaming Passthrough. Update naming of Thing to Chain and remove old Chain * Update docs/Customization/Dsptools-Blocks.rst Co-Authored-By: alonamid <alonamid@eecs.berkeley.edu> * Docummentation update for clarity and to explain how this can be applied to a generalized block * Some refactoring to get dsptools working with these examples * Oops, old files crept in Co-authored-by: Ryan Lund <ryan.lund@bwrcrdsl-4.eecs.berkeley.edu> Co-authored-by: Sagar Karandikar <sagark@eecs.berkeley.edu> Co-authored-by: alonamid <alonamid@eecs.berkeley.edu> Co-authored-by: Paul Rigge <rigge@berkeley.edu>
This commit is contained in:
@@ -5,7 +5,7 @@ LDFLAGS= -static
|
||||
|
||||
include libgloss.mk
|
||||
|
||||
PROGRAMS = pwm blkdev accum charcount nic-loopback big-blkdev pingd
|
||||
PROGRAMS = pwm blkdev accum charcount nic-loopback big-blkdev pingd passthrough fir
|
||||
|
||||
.DEFAULT_GOAL := default
|
||||
|
||||
|
||||
51
tests/fir.c
Normal file
51
tests/fir.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#define PASSTHROUGH_WRITE 0x2000
|
||||
#define PASSTHROUGH_WRITE_COUNT 0x2008
|
||||
#define PASSTHROUGH_READ 0x2100
|
||||
#define PASSTHROUGH_READ_COUNT 0x2108
|
||||
|
||||
#include "mmio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Starting writing\n");
|
||||
uint32_t num_tests = 15;
|
||||
uint32_t test_vector[15] = {1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 2};
|
||||
|
||||
for (int i = 0; i < num_tests; i++) {
|
||||
reg_write64(PASSTHROUGH_WRITE, test_vector[i]);
|
||||
}
|
||||
|
||||
printf("Done writing\n");
|
||||
uint32_t rcnt = reg_read32(PASSTHROUGH_READ_COUNT);
|
||||
printf("Write count: %d\n", reg_read32(PASSTHROUGH_WRITE_COUNT));
|
||||
printf("Read count: %d\n", rcnt);
|
||||
|
||||
int failed = 0;
|
||||
if (rcnt != 0) {
|
||||
for (int i = 0; i < num_tests - 3; i++) {
|
||||
uint32_t res = reg_read32(PASSTHROUGH_READ);
|
||||
uint32_t expected = 3*test_vector[i] + 2*test_vector[i+1] + test_vector[i+2];
|
||||
if (res == expected) {
|
||||
printf("\n\nPass: Got %d Expected %d\n\n", res, expected);
|
||||
} else {
|
||||
failed = 1;
|
||||
printf("\n\nFail: Got %d Expected %d\n\n", res, expected);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
printf("\n\nSome tests failed\n\n");
|
||||
} else {
|
||||
printf("\n\nAll tests passed\n\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
49
tests/passthrough.c
Normal file
49
tests/passthrough.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#define PASSTHROUGH_WRITE 0x2000
|
||||
#define PASSTHROUGH_WRITE_COUNT 0x2008
|
||||
#define PASSTHROUGH_READ 0x2100
|
||||
#define PASSTHROUGH_READ_COUNT 0x2108
|
||||
|
||||
#include "mmio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Starting writing\n");
|
||||
uint32_t test_vector[7] = {3, 2, 1, 0, -1, -2, -3} ;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
reg_write64(PASSTHROUGH_WRITE, test_vector[i]);
|
||||
}
|
||||
|
||||
printf("Done writing\n");
|
||||
uint32_t rcnt = reg_read32(PASSTHROUGH_READ_COUNT);
|
||||
printf("Write count: %d\n", reg_read32(PASSTHROUGH_WRITE_COUNT));
|
||||
printf("Read count: %d\n", rcnt);
|
||||
|
||||
int failed = 0;
|
||||
if (rcnt != 0) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
uint32_t res = reg_read32(PASSTHROUGH_READ);
|
||||
uint32_t expected = test_vector[i];
|
||||
if (res == expected) {
|
||||
printf("\n\nPass: Got %d Expected %d\n\n", res, test_vector[i]);
|
||||
} else {
|
||||
failed = 1;
|
||||
printf("\n\nFail: Got %d Expected %d\n\n", res, test_vector[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
printf("\n\nSome tests failed\n\n");
|
||||
} else {
|
||||
printf("\n\nAll tests passed\n\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user