From 798a0f167ee7fabdc24752aed1a4bd4799ef83ab Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 26 Feb 2019 15:12:45 +0800 Subject: [PATCH] ice40: hardcode ora_ptr The previous approach of attempting to derive it didn't work. It turns out that the ora_ptr is 16 * the current offset. Signed-off-by: Sean Cross --- ice40.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ice40.c b/ice40.c index 0693c25..9a67957 100644 --- a/ice40.c +++ b/ice40.c @@ -5,7 +5,9 @@ #define MAX(x, y) (x) > (y) ? (x) : (y) #define ARRAY_SIZE(x) ((sizeof(x) / sizeof(*x))) -#define DEBUG_PRINT(...) printf(__VA_ARGS__) +#define DEBUG_PRINT(...) +// #define DEBUG_PRINT(...) printf(__VA_ARGS__) +// #define SCAN_DEBUG // Make this a macro so line numbers work correctly #define assert_words_equal(check_word, old_word) \ @@ -37,10 +39,6 @@ #define SCAN_DEBUG_PRINT(...) #endif -// The number of words forward and backward to look for matches. -// Should be at least 16. -#define DIFF_FUZZ 32 - struct Ice40Bitstream { uint32_t offset; @@ -319,6 +317,7 @@ int ice40_patch(struct irw_file *f, struct irw_file *rom, (bs.current_width * bs.current_height) / 8); bs.bram_width = MAX(bs.bram_width, bs.current_width); bs.bram_height = MAX(bs.bram_height, bs.current_height); + ora_ptr = 16 * bs.current_offset; // Step 1: Find a mapping by scanning through the first 128 words looking for patterns. uint16_t scan_buffer[128]; @@ -448,13 +447,6 @@ int ice40_patch(struct irw_file *f, struct irw_file *rom, assert_words_equal(check_word, old_word); } - // Stash ora_ptr for the next bank iteration - if (word_stride != -1) { - int offset = (i / word_stride) * 16; - int mapping = word_mappings[i % word_stride].random; - ora_ptr = offset + mapping; - } - last0 = irw_readb(f); last1 = irw_readb(f); if (last0 || last1)