OpenCores
no use no use 1/1 no use no use
[or1ksim #16] Cleanup test peripheral
by Unknown on Feb 3, 2005
Not available!
Hi,

Starting with something really simple. This cleans up the test peripheral to be
more modular. This should give you a heads up on what the other peripherals are
in for...

ChangeLog:
* Cleanup test peripheral.

nog.
-------------- next part --------------
--- peripheral/test.c 2005-02-03 19:57:57.000000000 +0100
+++ ../or1ksim-ac/peripheral/test.c 2005-02-03 19:50:46.000000000 +0100
@@ -12,13 +12,18 @@
#include "abstract.h"
#include "except.h"

-uint32_t array[128];
+struct test_config {
+ uint32_t array[128];
+ oraddr_t baseaddr;
+};

/* Test write */
void test_write32 (oraddr_t addr, uint32_t value, void *dat)
{
+ struct test_config *test = dat;
+
if (addr & 0x00000080)
- array[addr & 0x7f] = value;
+ test->array[addr & 0x7f] = value;
else
except_handle(EXCEPT_BUSERR, cur_vadd);
}
@@ -26,41 +31,57 @@ void test_write32 (oraddr_t addr, uint32
/* Test read */
uint32_t test_read32 (oraddr_t addr, void *dat)
{
+ struct test_config *test = dat;
+
if (addr & 0x00000080)
- return ~array[addr & 0x7f];
+ return ~test->array[addr & 0x7f];
else
except_handle(EXCEPT_BUSERR, cur_vadd);
return 0x00000000;
}

-void test_reset ()
+void test_reset (void *dat)
{
+ struct test_config *test = dat;
int i;

for (i = 0; i - array = 0x00000000;
-
- if (config.test.enabled) {
- if (config.test.baseaddr)
- register_memoryarea(config.test.baseaddr, 256, 4, 0, test_read32, test_write32, NULL);
- }
+ test->array = 0x00000000;
}

/*---------------------------------------------------[ Test configuration ]---*/
-void test_enabled(union param_val val, void *dat)
+void test_baseaddr(union param_val val, void *dat)
{
- config.test.enabled = val.int_val;
+ struct test_config *test = dat;
+ test->baseaddr = val.addr_val;
}

-void test_baseaddr(union param_val val, void *dat)
+void *test_sec_start(void)
+{
+ struct test_config *test = malloc(sizeof(struct test_config));
+
+ if(!test) {
+ fprintf(stderr, "Peripheral Test: Run out of memory\n");
+ exit(-1);
+ }
+
+ test->baseaddr = 0;
+
+ return test;
+}
+
+void test_sec_end(void *dat)
{
- config.test.baseaddr = val.addr_val;
+ struct test_config *test = dat;
+ if(test->baseaddr)
+ register_memoryarea(test->baseaddr, 256, 4, 0, test_read32, test_write32, NULL);
+ reg_sim_reset(test_reset, dat);
}

void reg_test_sec(void)
{
- struct config_section *sec = reg_config_sec("test", NULL, NULL);
+ struct config_section *sec = reg_config_sec("test", test_sec_start,
+ test_sec_end);

- reg_config_param(sec, "enabled", paramt_int, test_enabled);
reg_config_param(sec, "baseaddr", paramt_addr, test_baseaddr);
}
--- sim-config.h 2005-02-03 18:48:40.000000000 +0100
+++ ../or1ksim-ac/sim-config.h 2005-02-03 20:12:22.000000000 +0100
@@ -266,13 +266,6 @@
int enable_bursts; /* Whether burst are enabled */
int no_multicycle; /* When enabled no multicycle paths are generated */
} cuc;
-
- struct {
- int enabled; /* Whether is test module enabled */
- unsigned long baseaddr; /* Base address */
- } test;
-
-
};

struct runtime {
--- sim-config.c 2005-02-03 18:48:40.000000000 +0100
+++ ../or1ksim-ac/sim-config.c 2005-02-03 20:13:23.000000000 +0100
@@ -174,9 +174,6 @@
config.cuc.enable_bursts = 1;
config.cuc.no_multicycle = 1;

- /* Test */
- config.test.enabled = 0;
-
#endif

/* Configure runtime */
no use no use 1/1 no use no use
© copyright 1999-2026 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.